[Unit]
Description=Hostapd IEEE 802.11 AP, IEEE 802.1X/WPA/WPA2/EAP/RADIUS Authenticator
# https://unix.stackexchange.com/questions/257888/systemd-wait-for-network-interface-to-be-up-before-running-service/417839#417839
# 2022-08-22: #3352 Raspberry Pi Zero W requires 2 lines below...
BindsTo=sys-subsystem-net-devices-{{ discovered_wireless_iface }}.device
After=sys-subsystem-net-devices-{{ discovered_wireless_iface }}.device
After=systemd-rfkill.service
Before=network.target
Wants=network-pre.target

[Service]
Type=idle
PIDFile=/run/hostapd.pid
ExecStartPre=-/usr/sbin/rfkill unblock wlan
ExecStart=/usr/sbin/hostapd -P /run/hostapd.pid /etc/hostapd/hostapd.conf

[Install]
WantedBy=multi-user.target
